# 使用示例
from api.service.rule_config_service import DictManager

def test_manager():
    # 创建管理器实例
    manager = DictManager()

    print("=== 字典操作演示 ===\n")

    # 增加
    manager.add("user1", {"name": "Alice", "age": 30, "city": "Beijing"})
    manager.add("user2", {"name": "Bob", "age": 25, "city": "Shanghai"})
    print()

    # 查询
    print("查询操作:")
    user1 = manager.get("user1")
    not_exist = manager.get("user3")
    print()

    # 列出所有
    manager.list_items()
    print()

    # 更新
    manager.update("user1", {"name": "Alice", "age": 31, "city": "Guangzhou"})
    manager.update("user3", {"name": "Charlie"})  # 不存在的键
    print()

    # 删除
    manager.delete("user2")
    manager.delete("user2")  # 再次删除不存在的键
    print()

    # 最终状态
    print("最终状态:")
    manager.list_items()
    print(f"字典大小: {manager.size()}")